import { defineStore } from 'pinia'
import type { IUSER } from '@/types'

export const useUserStore = defineStore(
  'userStore',
  () => {
    const user = ref<IUSER>({} as IUSER)
    const setUser = (item: IUSER) => {
      user.value = item
    }
    const clearUser = () => {
      user.value = {} as IUSER
    }
    return { user, setUser, clearUser }
  },
  {
    persist: {
      key: 'userStore',
      storage: sessionStorage
    }
  }
)
